# -*- coding: utf-8 -*-
# @Time    : 2020/4/28 8:04 下午
# @Author  : Liu minxuan
# @Email   : liuminxuan2016@gmail.com
# @File    : Demo5.py


import cv2 as cv
import numpy as np
count = 0
kernel = []
sums = 0
param_order = input("请输入掩膜的阶数(奇数):")
param_order = int(param_order)
for rows in range(param_order):
    kernel.append([])
    for cols in range(param_order):
        count += 1
        val = int(input("请输入第%d整数:\n" % count))
        kernel[rows].append(val)
        sums += val
Mask = np.array(kernel)
print(Mask)
print(Mask/sums)
Mask = Mask / sums
src_img = cv.imread("img/pinghua/dayanta_jiaoyan.bmp", cv.IMREAD_GRAYSCALE)
cv.imshow("src_img", src_img)
res = cv.filter2D(src_img, -1, Mask)
ret = cv.blur(src_img, (3, 3))
cv.imshow("res", res)
cv.imshow("ret", ret)
cv.waitKey(0)
cv.destroyAllWindows()





